//
// Created by zx208 on 2024/10/26.
//

// 已知链表的头结点L，链表中存在一个循环单链表，
// 设计将这部分循环单链表中所有结点的顺序完全倒置的算法

#include "../../SingleLinkedList/SingleLinkedList.h"

// 头插法 创建循环单链表
LinkedList Create_List_H(LinkedList head, int n){

    // 先创建头指针
    head = (LinkedList) malloc(sizeof( LNode));
    head->next = NULL;

    for (int i = 0; i < n; ++i) {
        LinkedList p = (LinkedList)malloc(sizeof( LNode));
        int data;
        scanf(" %d", &data);
        p->data = data;
        p->next = head->next;
        head->next = p;
    }

    LinkedList s = head->next;
    while(s->next) s = s->next;
    s->next = head;
    return head;
}

// 遍历链表全部元素
void PrintLL(LinkedList L){
    LNode *node = L->next;
    while(node != L){
        printf("%d ", node->data);
        node = node->next;
    }
}

// TODO
void Reverse(LinkedList L){

}

int main(void){
    LinkedList L = NULL;
    L = Create_List_H(L, 5);
    PrintLL(L);
    return 0;
}
